<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\helpers\Url;
use backend\assets\AppAsset;
use yii\widgets\Breadcrumbs;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php $this->registerCsrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<style>
    .layui-nav-tree .layui-this, .layui-nav-tree .layui-this>a, .layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a {
        background-color: #009688 !important;
    }
</style>
<div class="layadmin-tabspage-none" id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item layadmin-flexible" lay-unselect="">
                    <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                    </a>
                </li>
            </ul>
            <ul class="layui-nav layui-layout-right" style="padding-right: 15px;">
                <li class="layui-nav-item">
                    <a href="javascript:;"><img src="//t.cn/RCzsdCq" class="layui-nav-img"><?=!Yii::$app->user->isGuest?Yii::$app->user->identity->username:'未登录'?></a>
                    <dl class="layui-nav-child">
                        <dd><a href="<?=Url::toRoute('/user/logout')?>">退出</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-side-menu">
            <div class="layui-side-scroll">
                <div class="layui-logo" lay-href=""> <span><?=Yii::$app->params['backendName']?></span> </div>
                    <?php
                    $callback = function($menu){
                        $data = json_decode($menu['data'], true);
                        $items = $menu['children'];
                        $return = [
                            'label' => $menu['name'],
                            'url' => $menu['route']?[$menu['route']]:'javascript:;',
                        ];
                        //处理我们的配置
                        if ($data) {
                            //visible
                            isset($data['visible']) && $return['visible'] = $data['visible'];
                            //icon
                            isset($data['icon']) && $data['icon'] && $return['icon'] = $data['icon'];
                        }
                        //没配置图标的显示默认图标，默认图标大家可以自己随便修改
                        $items && $return['items'] = $items;

                        return $return;
                    };
                    echo \backend\widgets\Menu::widget([
                        'options'=>['class'=>'layui-nav layui-nav-tree', 'lay-shrink'=>'all', 'lay-filter'=>'layadmin-system-side-menu', 'id'=>'LAY-system-side-menu'],
                        'activateParents'=>true,
                        'items' => \mdm\admin\components\MenuHelper::getAssignedMenu(Yii::$app->user->id, null, $callback, true),
                    ]);
                    ?>
            </div>
        </div>
        <div class="layui-body" id="LAY_app_body">
            <div class="layadmin-tabsbody-item layui-show">
                <div class="layui-card layadmin-header">
                    <?= Breadcrumbs::widget([
                        'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
                        'itemTemplate' => "<a><cite>{link}</cite></a><span lay-separator=\"\">/</span>",
                        'activeItemTemplate' => "<a><cite>{link}</cite></a><span lay-separator=\"\">/</span>",
                        'tag' => 'div',
                        'options'=>['class'=>'layui-breadcrumb','lay-filter'=>'breadcrumb', 'style'=>'visibility: visible;']
                    ]) ?>
                </div>
                <div class="layui-fluid">
                    <?= $content ?>
                </div>
            </div>
        </div>

    </div>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
